<include file="Common/common" />
<?php $statusArr = array('1'=>'等待买家上传凭证','2'=>'等待卖家确认','3'=>'订单完成'); ?>

<body>
	<div class="layui-tab-item layui-show">
		<div class="layui-main">
			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			  	<legend style="color: rgb(240,222,112);">挂卖报表</legend>
			</fieldset>
			<div style="overflow-x: auto;">
				<table class="layui-table" style="color: rgb(240,222,112);" >
					<thead>
							<tr style="background: rgb(57,61,73)">
								<th>编号</th>
								<th>购买用户</th>
								<th>联系电话</th>
								<!-- <th>出售用户</th> -->
								<th>积分数量</th>
								<th>订单时间</th>
								<!-- <th>付款时间</th>
								<th>完成时间</th> -->
								<th>查看凭证</th>
								<th>状态</th>
								<!-- <th>备注</th> -->
								<th>操作</th>
							</tr> 
						</thead>
						<tbody>
							<foreach name="sellList" item="vo">
								<tr  style="background: #7d7d7d;color:rgb(240,222,112);">
									<td>{$vo['id']}</td>
									<td>{$vo['buy_account']}</td>
									<td>{$vo['buyphone']}</td>
									<!-- <td>{$vo['sell_account']}</td> -->
									<td>{$vo['num']}</td>
									<td><?php if(!empty($vo['createtime'])){echo date('Y-m-d H:i:s',$vo['createtime']);} ?></td>
									<!-- <td><?php if(!empty($vo['paytime'])){echo date('Y-m-d H:i:s',$vo['paytime']);} ?></td>
									<td><?php if(!empty($vo['finishtime'])){echo date('Y-m-d H:i:s',$vo['finishtime']);} ?></td> -->
									<td>
										<if condition="$vo['status'] egt 1"><button  style="color: rgb(240,222,112);background: rgb(57,61,73);font-size: 16px"  class="layui-btn" onclick="func_show(this,{$vo['id']})" >查看凭证</button></if>
									</td>
									<td><span style="color:rgb(240,222,112);">{$statusArr[$vo['status']]}</span></td>
									<td>
										<if condition="$vo['status'] eq 1 or $vo['status'] eq 2"><button  style="color: rgb(240,222,112);background: rgb(57,61,73);font-size: 16px"  class="layui-btn" onclick="func_finish(this,{$vo['id']})" >确认完成</button></if>
									</td>
								</tr>
							</foreach>
						</tbody>
				</table>
			</div>
			<div class="green-black">{$page}</div>
		</div>
	</div>
</body>
<script type="text/javascript">

	// 卖家确认
	function func_finish(obj,id){
		layer.confirm('请确认操作',{offset:'none'},function(index){
			$.ajax({
	            type: "post",
	            url: "{:U('Order/ctrl_finish')}",
	            data: {id:id},
	            dataType: "json",
	            success: function(rtJson){
	            	if (rtJson.code == 1) {
                        layer.msg('<span style="color: rgb(240,222,112);">'+rtJson.msg+'</span>');
	            		setTimeout(function(){location.reload();}, 1000);
	            	}else{
                        layer.msg('<span style="color: rgb(240,222,112);">'+rtJson.msg+'</span>');
	            	}
	               	
	            }
	        });
		});
	}
	
	// 查看打款凭证
	function func_show(obj,id){
		
		layer.open({
			type: 2,
			title: '编号：'+id,
			shadeClose: true,
			shade: 0.8,
			scrollbar: false,
			area: ['100%', '100%'],
			content: "/Order/show?id="+id, //iframe的url
			
		});
	}
</script>
<include file="Common/footer" />